
/**************************************************************************************************/
/*                                    All of those crazy verbs!                                   */
/**************************************************************************************************/

client/verb
	Say(msg as text)
		set
			hidden = 1
			name = ">"
		if(src.key in MuteList)
			return 0
		else
			if(msg&&msg!=null)
				if(src.Colors == 1)
					world<<"<b>\[</b>[time2text(world.timeofday,"hh:mm:ss")]<b>\] <font color='[html_encode(Name_Color)]'>[src.key]</font></b>: <font color='[html_encode(Text_Color)]'>[html_encode(msg)]</font>"
				else
					world<<"<b>\[</b>[time2text(world.timeofday,"hh:mm:ss")]<b>\] [src.key]</b>: [html_encode(msg)]"
			if(src.Status != "Available")
				src.Status = "Available"

	Emote(msg as text) {
		set {
			hidden = 1
			name = "me"
		}

		if(msg) {
			if(src.Colors == 1) {
				world<<"<b>\[</b>[time2text(world.timeofday,"hh:mm:ss")]<b>\]</b> *<font color='[html_encode(Name_Color)]'>[src.key] [html_encode(msg)]</font>"
			}
			else {
				world<<"<b>\[</b>[time2text(world.timeofday,"hh:mm:ss")]<b>\]</b> *[src.key] [html_encode(msg)]"
			}
		}
		if(!src.Status) {
			src.Status=!src.Status
		}
	}

	ControlCenter() {
		set
			hidden = 1
			name = "Controls"
		var
			FullPage
			Header = {"<html>
	<head>
		<title>Control Center</title>"}

			Footer = "</body></html>"

			Javascript = {"
			<script style = "text/javascript">
				function send() {

				  if(document.controlpanel.togglecolor\[0].checked) { var togglecolor = "on" }
				  else if(document.controlpanel.togglecolor\[1].checked) { var togglecolor = "off" }

				  if(document.controlpanel.paneside\[0].checked) { var paneside = "left" }
				  else if(document.controlpanel.paneside\[1].checked) { var paneside = "right" }

				  var namecolor = document.controlpanel.namecolor.value;
				  var textcolor = document.controlpanel.textcolor.value;
				  var outputstyle = document.controlpanel.outputstyle.value;

				  if(document.controlpanel.userstatus\[0].checked) { var userstatus = "available" }
				  else if(document.controlpanel.userstatus\[1].checked) { var userstatus = "away" }
				  else if(document.controlpanel.userstatus\[2].checked) { var userstatus = "busy" }

				  var status = document.controlpanel.status.value;

				  location.href='byond://?src=\ref[src];action=ControlPanel;togglecolor='+togglecolor+';paneside='+paneside+';namecolor='+namecolor+';textcolor='+textcolor+';outputstyle='+outputstyle+';userstatus='+userstatus+';status='+status
				}
			</script>
			"}
			CSS = {"<style type = "text/css">
	body{background: #000; color: #CCC;}
	.controls{background: #1133FF; border: 2px groove #1133FF; width: 400px; padding: 0px; position: absolute; left: 0px; top: 0px}
	.controls td, .controls th{background: #000; border: 2px groove #66AADD;}
	.select select{width: 100%;}
	.input input{width: 100%;}
</style>"}

			Page={"<form name="controlpanel" method="get">
		<table class="controls">
			<tr><th colspan="2">User Settings</th></tr>
			<tr>
				<td>Toggle Colors:</td>
				<td><input type="radio" name="togglecolor" value="on" checked="checked" />On <input type="radio" name="togglecolor" value="off"/>Off</td>
			</tr>
			<tr>
				<td>User List:</td>
				<td><input type="radio" name="paneside" value="left" checked="checked" />Left <input type="radio" name="paneside" value="right"/>Right</td>
			</tr>
			<tr>
				<td>Name Color:</td>
				<td class="input"><input type="text" name="namecolor" value="[src.Name_Color]"/></td>
			</tr>
			<tr>
				<td>Text Color:</td>
				<td class="input"><input type="text" name="textcolor" value="[src.Text_Color]"/></td>
			</tr>
			<tr>
				<td>Output Style:</td>
				<td class="input"><input type="text" name="outputstyle" value="[src.Output_Style]"/></td>
			</tr>
			<tr>
				<td>Status:</td>
				<td><input type="radio" name="userstatus" value="available" checked="checked" />Available <input type="radio" name="userstatus" value="away"/>Away <input type="radio" name="userstatus" value="busy"/>Busy</td>
			</tr>
			<tr>
				<td colspan="2"class="input"><input type="text" name="status" value="I have gone away."/></td>
			</tr>
			<tr>
				<th colspan="2" align="right"><input type="button" name="submit" value="Submit" onclick="send(this.form)" /></th>
			</tr>
		</table>
	</form>"}



		FullPage = "[Header][Javascript][CSS][Page][Footer]"
		src<<browse(FullPage,"window=moderation;size=400x280;can_resize=0")
	}


client/Topic(href,href_list[])
	..()
	switch(href_list["action"])
		if("ControlPanel") {

			// TOGGLE COLORS
			if(href_list["togglecolor"]=="on") {
				src.Colors = 1

			}
			else {
				src.Colors = 0
			}

			// USER LIST
			if(href_list["paneside"]=="right" && src.WhoSide=="Left") {
				var/splitter = text2num(winget(src,"Main.MainChild","splitter"))
				winset(src,"Main.MainChild","splitter=[100-splitter]")
				winset(src,"Main.MainChild","left=Output")
				winset(src,"Main.MainChild","right=WhoList")
				winset(src,"Main.LeftChatters","is-visible=false")
				winset(src,"Main.RightChatters","is-visible=true")
				winset(src,"Main.Topic","pos=0,0")
				src.WhoSide = "Right"
			}
			else if(href_list["paneside"]=="left" && src.WhoSide=="Right") {
				var/splitter = text2num(winget(src,"Main.MainChild","splitter"))
				winset(src,"Main.MainChild","splitter=[100-splitter]")
				winset(src,"Main.MainChild","left=WhoList")
				winset(src,"Main.MainChild","right=Output")
				winset(src,"Main.LeftChatters","is-visible=true")
				winset(src,"Main.RightChatters","is-visible=false")
				winset(src,"Main.Topic","pos=132,0")
				src.WhoSide = "Left"
			}
			// NAME COLOR
			src.Name_Color = href_list["namecolor"]
			// TEXT COLOR
			src.Text_Color = href_list["textcolor"]
			// OUTPUT STYLE
			src.Output_Style = href_list["outputstyle"]
			winset(src,"Output.Output","style=\"body{font-family:[Output_Style]}")
			// STATUS
			if(href_list["userstatus"]=="available") {
				if(src.Status!="Available") {
					src.Status = "Available"
					world<<"<b>\[</b>[time2text(world.timeofday,"hh:mm:ss")]<b>\] <font color='[html_encode(Bot_Color)]'>@Wench</font></b>: [src.key] has returned!"
				}
			}
			else if(href_list["userstatus"]=="away") {
				if(src.Status == "Available") {
					world<<"<b>\[</b>[time2text(world.timeofday,"hh:mm:ss")]<b>\] <font color='[html_encode(Bot_Color)]'>@Wench</font></b>: [src.key] has gone away. ([href_list["status"]])"
				}
				src.Status = "Away"
			}
			else if(href_list["userstatus"]=="busy") {
				if(src.Status == "Available") {
					world<<"<b>\[</b>[time2text(world.timeofday,"hh:mm:ss")]<b>\] <font color='[html_encode(Bot_Color)]'>@Wench</font></b>: [src.key] is now busy. ([href_list["status"]])"
				}
				src.Status = "Busy"
			}
		}